<?php

include "../init.php";
include DIR_CORE."/MySQLDB.php";

// 接收数据
$rep_content = escapeString($_POST['rep_content']);
$rep_pub_id = $pub_id = $_GET['pub_id'];
$rep_quote_id = $rep_id = $_GET['rep_id'];
$rep_num = $num = $_GET['num'];

// 判断数据的合法性
if (empty($rep_content)) {
    jump("./quote.php?num=$num&pub_id=$pub_id&rep_id=$rep_id", "回复内容不能为空！");
}

// 数据入库
session_start();

// echo "<pre>";
// print_r($_SESSION);
// echo "</pre>";

$rep_user = $_SESSION['userInfo']['user_name'];
$rep_time = time();
$sql = "insert into reply values(null, $rep_pub_id, '$rep_user', '$rep_content', '$rep_time', '$rep_num', '$rep_quote_id')";
$result = my_query($sql);

if ($result) {
    jump("./show.php?pub_id=$pub_id&action=reply", "回复成功！");
} else {
    jump("./quote.php?num=$num&pub_id=$pub_id&rep_id=$rep_id", "回复失败！");
}

?>
